<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>注册页面</title>
	<link rel="stylesheet" href="${basePath}/front/css/register.css">
</head>
<body>
	<div class="dress">
		<img src="${basePath}/front/images/login02.jpg" width="300">
	</div>
	<div class="login">
		<h1>欢迎注册&nbsp;&nbsp;<i>Tomorrow</i>博客</h1>
		<p class="h1p1">Tomorrow will be better.</p>
		<p class="h1p2">Tomorrow there will be good things waiting for you.</p>
		<p class="h1p3">Tomorrow Blog</p>
		<form action="/user/front/register" onsubmit="return false;" method="post" id="registerForm">
			<div class="userName">
				<label>用户名</label>
				<input type="text" name="userName" class="inputAni">
				<span class=""></span>
			</div>
			<div class="userPassword">
				<label>密&nbsp;&nbsp;码</label>
				<input type="text" name="userPassword" class="inputAni">
				<span class="spanAni"></span>
			</div>
			<input type="submit" value="注册" class="submit" id="registerSubmit">
			<input type="reset" value="重置" class="reset">
			<a href="/front/login.jsp" class="register">已有账号？点击登录!</a>
		</form>
	</div>

	<script src="../../front/js/jquery-1.9.1.min.js"></script>

<script type="text/javascript">
	$(function () {
		$("#registerForm").submit(function () {
            var postData = $("#registerForm").serialize();
            $.ajax({
                type: "POST",
                url: "/user/front/register",
                data: postData,
                beforeSend: function() {
                    $("#registerSubmit").attr("disabled", true);//提交表单前的处理，防止用户多次点击【登陆】，重复提交表单
                },
                success: function(data) {
                    if (data.success) {
                            alert('注册成功,前往登录！');
                        window.location.href = '${basePath}/front/login.jsp';
                    } else {
                        $("#registerSubmit").attr("disabled", false);
                        $("#registerSubmit").val("注册");
                        alert(data.msg);
                    }
                }
			})
        })
    })
</script>
</body>
</html>